import router from "../router/index.js"
import {ElMessage} from "element-plus";
import http from "@/utils/http.js";

const tools = {

    isLogin() {
        return localStorage.getItem("currentUser") !== null;
    },
    getCurrentUser() {
        return JSON.parse(localStorage.getItem("currentUser"));
    },
    getToken() {
        return localStorage.getItem("token");
    },
}

export function updateUserInfo(newInfo) {
  const user = JSON.parse(localStorage.getItem('user'))
  if (user) {
    user.name = newInfo.name
    user.gender = newInfo.gender
    // 更新其他需要同步的字段
    localStorage.setItem('user', JSON.stringify(user))
  }
}

export default tools
